package cn.wit.test;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginServlet extends HttpServlet{
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		String uesr = req.getParameter("User");
		String password = req.getParameter("password");
		
		if("admin".equals(uesr)&&"admin".equals(password)) {
			
			//跳到成功页面
			resp.sendRedirect("success.jsp");
			
		}else {
			
			req.setAttribute("error", "用户名或密码不对");
			
			//跳到登陆页面
			req.getRequestDispatcher("login.jsp").forward(req, resp);;
			
		}
		
	}

}
